home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / console / svgatext.3 / svgatext / SVGATextMode-1.3 / contrib / vgaset / compiler.h next >
Encoding:
C/C++ Source or Header  |  1992-11-02  |  3.7 KB  |  199 lines

  1. /* $Header: /S/X/vgaset-1.1/RCS/compiler.h,v 1.1 1992/11/02 22:44:36 grog Exp $ */
  2. /*
  3.  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
  4.  *
  5.  * Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both that
  8.  * copyright notice and this permission notice appear in supporting
  9.  * documentation, and that the name of Thomas Roell not be used in
  10.  * advertising or publicity pertaining to distribution of the software without
  11.  * specific, written prior permission.  Thomas Roell makes no representations
  12.  * about the suitability of this software for any purpose.  It is provided
  13.  * "as is" without express or implied warranty.
  14.  *
  15.  * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17.  * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  20.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21.  * PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * $Header: /S/X/vgaset-1.1/RCS/compiler.h,v 1.1 1992/11/02 22:44:36 grog Exp $
  24.  */
  25.  
  26.  
  27. #ifndef _COMPILER_H
  28. #define _COMPILER_H
  29.  
  30. #ifdef __GNUC__
  31.  
  32. #ifndef FAKEIT
  33. #ifdef GCCUSESGAS
  34.  
  35. /*
  36.  * If gcc uses gas rather than the native assembler, the syntax of these
  37.  * inlines has to be different.        DHD
  38.  */
  39.  
  40. static __inline__ void
  41. outb(port, val)
  42. short port;
  43. char val;
  44. {
  45.    __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
  46. }
  47.  
  48.  
  49. static __inline__ void
  50. outw(port, val)
  51. short port;
  52. short val;
  53. {
  54.    __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
  55. }
  56.  
  57. static __inline__ unsigned int
  58. inb(port)
  59. short port;
  60. {
  61.    unsigned char ret;
  62.    __asm__ __volatile__("inb %1,%0" :
  63.        "=a" (ret) :
  64.        "d" (port));
  65.    return ret;
  66. }
  67.  
  68. static __inline__ unsigned int
  69. inw(port)
  70. short port;
  71. {
  72.    unsigned short ret;
  73.    __asm__ __volatile__("inw %1,%0" :
  74.        "=a" (ret) :
  75.        "d" (port));
  76.    return ret;
  77. }
  78.  
  79. #else    /* GCCUSESGAS */
  80.  
  81. static __inline__ void
  82. outb(port, val)
  83.      short port;
  84.      char val;
  85. {
  86.   __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
  87. }
  88.  
  89. static __inline__ void
  90. outw(port, val)
  91.      short port;
  92.      short val;
  93. {
  94.   __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
  95. }
  96.  
  97. static __inline__ unsigned int
  98. inb(port)
  99.      short port;
  100. {
  101.   unsigned int ret;
  102.   __asm__ __volatile__("in%B0 (%1)" :
  103.            "=a" (ret) :
  104.            "d" (port));
  105.   return ret;
  106. }
  107.  
  108. static __inline__ unsigned int
  109. inw(port)
  110.      short port;
  111. {
  112.   unsigned int ret;
  113.   __asm__ __volatile__("in%W0 (%1)" :
  114.            "=a" (ret) :
  115.            "d" (port));
  116.   return ret;
  117. }
  118.  
  119. #endif /* GCCUSESGAS */
  120.  
  121. #ifdef linux
  122.  
  123. #define intr_disable()
  124. #define intr_enable()
  125.  
  126. #else /* !linux */
  127.  
  128. static __inline__ void
  129. intr_disable()
  130. {
  131.   __asm__ __volatile__("cli");
  132. }
  133.  
  134. static __inline__ void
  135. intr_enable()
  136. {
  137.   __asm__ __volatile__("sti");
  138. }
  139.  
  140. #endif /* else !linux */
  141.  
  142. #else /* FAKEIT */
  143.  
  144. static __inline__ void
  145. outb(port, val)
  146.      short port;
  147.      char val;
  148. {
  149. }
  150.  
  151. static __inline__ void
  152. outw(port, val)
  153.      short port;
  154.      short val;
  155. {
  156. }
  157.  
  158. static __inline__ unsigned int
  159. inb(port)
  160.      short port;
  161. {
  162.   return 0;
  163. }
  164.  
  165. static __inline__ unsigned int
  166. inw(port)
  167.      short port;
  168. {
  169.   return 0;
  170. }
  171.  
  172. static __inline__ void
  173. intr_disable()
  174. {
  175. }
  176.  
  177. static __inline__ void
  178. intr_enable()
  179. {
  180. }
  181.  
  182. #endif /* FAKEIT */
  183.  
  184. #else /* __GNUC__ */
  185. # if defined(__STDC__) && (__STDC__ == 1)
  186. #  define asm __asm
  187. # endif
  188. #include <sys/inline.h>
  189. #define intr_disable() asm("cli")
  190. #define intr_enable()  asm("sti")
  191. #endif
  192.  
  193. #ifndef __STDC__
  194. #define signed /**/
  195. #define const /**/
  196. #endif
  197.  
  198. #endif /* _COMPILER_H */
  199.